import { defineStore } from 'pinia';


export const useUserStore = defineStore({
    id: 'userModule',
    state: () => ({
        username_return: null as string | null,
        user_id_return: null as string | null,
        username_lend: null as string | null,
        user_id_lend: null as string | null,
    }),
    actions: {
        setLendUserInfo(username_lend: string, user_id_lend: string) {
            this.username_lend = username_lend;
            this.user_id_lend = user_id_lend;
            // 如果return信息为空,那么顺带设置了
            if(this.username_return === null){
                this.username_return = username_lend
                this.user_id_return = user_id_lend
            }
        },
        setReturnUserInfo(username_return: string, user_id_return: string){
            this.username_return = username_return;
            this.user_id_return = user_id_return;
            if(this.username_lend === null){
                this.username_lend = username_return
                this.user_id_lend = user_id_return
            }
        }
    },
});
